package com.pan.games.leecode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author by panstark
 * @description
 * @notice
 * @date 2021/3/31
 */
public class LongestSunCharactor {

    public static void main(String[] args) {

        String str = "abcabcbb";
        int size  = getLonggestSonStr(str);
        System.out.println("size:"+size);

    }

    private static int getLonggestSonStr(String s) {
        //s= s.replace(" ","-");
        char[] chars = s.toCharArray();
        List<Character> stringList = new ArrayList<>();
        int maxSize = 0;
        int currentSize = 0;
        for (int i = 0; i < chars.length; i++) {
            stringList.clear();
            for (int i1 = i; i1 < chars.length; i1++) {
                if(stringList.contains(chars[i1])){
                    break;
                }else{
                    stringList.add(chars[i1]);
                    currentSize=stringList.size();
                    if(maxSize<currentSize){
                        maxSize=currentSize;
                        System.out.println("i:"+i+","+"i1:"+i1+",size:"+maxSize);
                    }
                    System.out.println("---i:"+i+","+"i1:"+i1+",size:"+maxSize);
                }
            }
        }

        return maxSize;

    }
}
